<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">

  </div>
</template>

<script>
// @ is an alias to /src
// 配置参数

import axios from 'axios'

export default {
  name: '',
  components: {

  },
  created () {
    axios.create({
      baseURL: 'htpp://localhost:8080',//请求的域名，基本地址
      timeout: 1000,//请求超时时长（ms)\
      url: '/data.json',//请求路径
      method: 'get,post,put,patch,delete',
      headers: {
        token: ''
      },//设置请求头
      params: {

      },//请求参数拼接在url
      data: {

      }//请求参数放在请求体

    })
    axios.get('/data.json', {      params{

      }    })
    //1.axios全局配置
    axios.defaults.timeout = 1000
    axios.defaults.baseURL = 'http://localhost:8080'
    //2.axios实例配置
    let instance = axios.create()
    instance.defaults.timeout = 3000
    //3.axios请求配置最高
    instance.get('/data.json',{
      timeout:5000
    })

    //实际开发
    //两种请求接口
    //http:localhost:9090
    //http:localhost:9091
    let instance = axios.create({
      baseURL:'http:localhost:9090',
      timeout:1000
    })
    let instance = axios.create({
      baseURL:'http:localhost:9091',
      timeout:3000
    })
    //baseurl,timeout,url,method
    instance.get('/contacList',{
      params:{}
    }).then((res)=>{
      console.log(res)
    })
    instance.get('/orderList',{
      timeout:5000
    }).then((res)=>{
      console.log(res)
    })
  },
}
</script>
